package com.jims.master.modules.utils;

import com.jims.master.common.utils.SpringContextHolder;
import com.jims.master.modules.blood.dao.*;
import com.jims.master.modules.blood.entity.*;
import com.jims.master.modules.blood.vo.UseBloodInfoVo;
import com.jims.master.modules.sys.dao.PersonInfoDao;
import com.jims.master.modules.sys.utils.UserUtils;

import java.util.List;

/**
 * Created by fengyg on 2017/4/13.
 */
public class BloodUtils {
    private static BloodComponentDao bloodComponentDao = SpringContextHolder.getBean(BloodComponentDao.class);
    private static UseBloodInfoVoDao useBloodInfoVoDao = SpringContextHolder.getBean(UseBloodInfoVoDao.class);
    private static BloodMatchDao bloodMatchDao = SpringContextHolder.getBean(BloodMatchDao.class);
    private static BloodApplyDao bloodApplyDao = SpringContextHolder.getBean(BloodApplyDao.class);
    private static BloodOutSheetDao bloodOutSheetDao = SpringContextHolder.getBean(BloodOutSheetDao.class);
    private static PersonInfoDao personInfoDao = SpringContextHolder.getBean(PersonInfoDao.class);
    private static BloodInpMasterDao bloodInpMasterDao = SpringContextHolder.getBean(BloodInpMasterDao.class);
    private static BloodInpDetailDao bloodInpDetailDao = SpringContextHolder.getBean(BloodInpDetailDao.class);
    private static BloodOutpMasterDao bloodOutpMasterDao = SpringContextHolder.getBean(BloodOutpMasterDao.class);

    /**
     * 获取血液成分列表
     * @return
     * @author fengyg
     */
    public static List<BloodComponent> getComponentList() {
        BloodComponent component = new BloodComponent();
        component.preUpdate();
        return bloodComponentDao.findList(component);
    }

    /**
     * 申请单号翻译
     * @param id
     * @return
     */
    public static String getApplyNum(String id){
        return bloodApplyDao.get(id).getApplyNum();
    }

    /**
     * 血液成分字典翻译
     * @param id
     * @return
     * @author fengyg
     */
    public static String getBloodComponentName(String id){
        return bloodComponentDao.get(id).getBloodName();
    }

    /**
     * 获取所有住院患者信息
     * @return
     * @author fengyg
     */
    public static List<UseBloodInfoVo> getPatientInHospList(){
        List<UseBloodInfoVo> list = useBloodInfoVoDao.getPatientInHospList(UserUtils.getOrgId());
        return list;
    }

    /**
     * 获取所有配血单号
     * @return
     * @author fengyg
     */
    public static List<BloodMatch> getMatchSheetNumList(){
        return bloodMatchDao.getMatchSheetNumList(UserUtils.getOrgId());
    }

    /**
     * 获取所有发血单号
     * @return
     * @author fengyg
     */
    public static List<BloodOutSheet> getBloodOutNumList(){
        return bloodOutSheetDao.getBloodOutNumList(UserUtils.getOrgId());
    }

    /**
     * 获取所有血袋号(发血单里)
     * @return
     * @author fengyg
     */
    public static List<BloodOutSheet> getBloodIdList(){
        return bloodOutSheetDao.getBloodIdList(UserUtils.getOrgId());
    }

    /**
     * 获取所有入库单号
     * @return
     * @author fengyg
     */
    public static List<BloodInpMaster> getInpNoList(){
        BloodInpMaster master = new BloodInpMaster();
        master.updateOrgId();
        return bloodInpMasterDao.getInpNoList(master);
    }

    /**
     * 获取所有出库单号
     * @return
     * @author fengyg
     */
    public static List<BloodOutpMaster> getOutpNoList(){
        BloodOutpMaster bloodOutpMaster = new BloodOutpMaster();
        bloodOutpMaster.updateOrgId();
        return bloodOutpMasterDao.getOutpNoList(bloodOutpMaster);
    }

    /**
     * 获取所有血袋号(入库明细里)
     * @return
     * @author fengyg
     */
    public static List<BloodInpDetail> getBloodIds(){
        return bloodInpDetailDao.getBloodIdList(UserUtils.getOrgId());
    }

    /**
     * 根据用户ID查询名称
     * @param userId
     * @return
     * @author fengyg
     */
    public static String getNameByUserId(String userId){
        return personInfoDao.getNameByUserId(userId).getName();
    }

    /**
     * 配血单号翻译
     * @param id
     * @return
     * @author fengyg
     */
    public static String getMatchNum(String id){
        return bloodMatchDao.get(id).getMatchSheetNum();
    }
}
